package com.guigu.pd.base.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.common.utils.PageVo;
import com.guigu.pd.base.entity.GoodsTypeEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.common.utils.PageUtils;
import com.guigu.common.utils.Query;

import com.guigu.pd.base.dao.TruckTypeDao;
import com.guigu.pd.base.entity.TruckTypeEntity;
import com.guigu.pd.base.service.TruckTypeService;
import org.springframework.util.ObjectUtils;


@Service("truckTypeService")
public class TruckTypeServiceImpl extends ServiceImpl<TruckTypeDao, TruckTypeEntity> implements TruckTypeService {


    @Override
    public PageVo<TruckTypeEntity> querytrucktypefy(TruckTypeEntity truckType,Integer pageNum, Integer pagesize) {

        QueryWrapper<TruckTypeEntity> queryWrapper = new QueryWrapper<TruckTypeEntity>();
        if (ObjectUtils.isEmpty(truckType)) {
            queryWrapper.like("name", truckType.getName());
        }
        PageHelper.startPage(pageNum, pagesize);

        List<TruckTypeEntity> list = this.list(queryWrapper);

        PageInfo<TruckTypeEntity> pageInfo = new PageInfo<>(list);

        PageVo<TruckTypeEntity> pageVo = new PageVo<>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }
}